﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>菜单管理</title>
    <#include "/common/link.ftl">
    <script>
        $(function () {


            $(".btn-status").click(function () {

                var status = $(this).data("status");
                var id = $(this).data("id");
                var msg = "确定启动吗?"
                if (status == 1) {
                    msg = "确定禁止吗?"
                }
                Swal.fire({
                    title: msg,
                    text: "大家好才是真打好!",
                    icon: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消!'
                }).then((result) => {
                    if (result.value) {
                        window.location.href = "/menuCatalogue/updateStatus?id=" + id + "&status=" + status;
                    }
                });
            })
        })
    </script>
</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">
    <#include "/common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="systemMenu"/>
    <#include "/common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>菜单管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <div style="margin: 20px 0px 0px 10px">
                    <form class="form-inline" id="searchForm" action="/menuCatalogue/list" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                        <div class="form-group">
                            <label>菜单名称</label>
                            <input type="text" class="form-control" placeholder="请输入菜单名称" name="name"
                                   value="${qo.name}">
                        </div>
                        <div class="form-group">
                            <label>菜单地址</label>
                            <input type="text" class="form-control" placeholder="请输入菜单地址" name="url" value="${qo.url}">
                        </div>
                        <div class="form-group">
                            <label>菜单状态</label>
                            <select class="form-control" name="status" id="statusId">
                                <option value="-1">全部</option>
                                <option value="0">启用</option>
                                <option value="1">禁用</option>
                            </select>
                            <script>
                                $("#statusId").val('${qo.status}')
                            </script>
                        </div>
                        <div class="form-group">
                            <label>菜单类型</label>
                            <select class="form-control" name="menuType" id="menuTypeId">
                                <option value="-1">全部</option>
                                <option value="0">目录</option>
                                <option value="1">菜单</option>
                            </select>
                            <script>
                                $("#menuTypeId").val('${qo.menuType}')
                            </script>
                        </div>

                        <button type="submit" class="btn btn-primary">
                            <span class="glyphicon glyphicon-search"></span> 查询
                        </button>

                        <a href="#" class="btn btn-success btn-input">
                            <span class="glyphicon glyphicon-plus"></span> 添加
                        </a>
                    </form>

                </div>
                <div class="box-body table-responsive ">
                    <table class="table table-hover table-bordered table-striped">
                        <thead>
                        <tr>
                            <th>编号</th>
                            <#--                        <th>菜单图标</th>-->
                            <th>菜单类型</th>
                            <th>菜单名称</th>
                            <th>上级菜单</th>
                            <th>菜单URL</th>
                            <th>权限表达式</th>
                            <th>排序</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list pageInfo.list as p>
                            <tr>
                                <td>${p_index + 1 !}</td>
                                <td>${p.menuTypeDisplay !}</td>
                                <td>${p.name !}</td>
                                <td>${p.superiorName !}</td>
                                <td>${p.url !}</td>
                                <td>${p.jurisdiction !}</td>
                                <td>${p.ranking !}</td>
                                <td>${p.statusDisplay !}</td>
                                <td>
                                    <a href="#" class="btn btn-info btn-xs btn-input" data-json='${p.toJson()}'>
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                    <a class="btn btn-xs btn-primary btn-status" data-status="0" data-id="${p.id}">
                                        <span class="glyphicon glyphicon-phone-alt"></span> 启用</a>
                                    <a class="btn btn-xs btn-danger btn-status" data-status="1" data-id="${p.id}">
                                        <span class="glyphicon glyphicon-remove"></span> 禁用</a>
                                </td>
                            </tr>
                        </#list>

                        </tbody>
                    </table>
                    <!--分页-->
                    <#include "/common/page.ftl">
                </div>

            </div>
        </section>
    </div>
    <#include "/common/footer.ftl">
</div>

<script>

    $(".btn-input").click(function () {
        var $btn = $(this);
        var data = $btn.data('json');

        // 清楚模态框之前显示的数据
        $('#editForm input[name]').val('');

        if (data) {

            $('#editForm input[name=id]').val(data.id);
            $('#editForm input[name=name]').val(data.name);
            $('#editForm input[name=url]').val(data.url);
            $('#editForm input[name=jurisdiction]').val(data.jurisdiction);
            $('#editForm input[name=ranking]').val(data.ranking);
            $('#editForm input[name=status]').val(data.status);
            $('#editForm input[name=menuType]').val(data.menuType);
            $('#editForm input[name=superiorName]').val(data.superiorName);
            $('#editForm input[name=content]').val(data.content);

        }
        //业务回显
        $("#superiorName").val(json.categoryParentId);

        //有些浏览器不能触发事件,建议使用下面操作
        //$("#businessCategory").change();

        var html = " <option value='-1'>请选择预约业务</option>";
        $.get("/systemDictionary/queryByParentId", {parentId:json.categoryParentId},function (data) {
            $.each(data, function(index, item) {
                html += "<option value='"+item.id+"'>"+item.name+"</option>"
            })
            $("#businessModal").html(html)
            $("#businessModal").val(json.categoryId);
        })
    }
        $("#editModal").modal('show')
    })
</script>

<!-- Modal -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel">新增/编辑</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
            </div>

            <form id="editForm" action="/menuCatalogue/saveOrUpdate" method="post">
                <div class="modal-body">
                    <input type="hidden" name="id">
                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">菜单类型：</label>
                        <div class="col-sm-7">
                            <label>
                                <input type="radio" name="menuType" value="0" checked>
                                目录
                            </label>
                            <label>
                                <input type="radio" name="menuType" value="1">
                                菜单
                            </label>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">菜单名称：</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control " id="name" name="name" placeholder="请输入菜单名称"/>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">上级菜单：</label>
                        <div class="col-sm-7">
                            <select class="form-control" name="superiorName" id="superiorName">
                                <option value="1">门店管理</option>
                                <option value="2">系统管理</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">菜单URL：</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="url" name="url"
                                   placeholder="请输入菜单URL">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">菜单序号：</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="ranking" name="ranking"
                                   placeholder="请输入菜单序号">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">菜单图标：</label>
                        <div class="col-sm-7" style="color:lightslategrey">
                            <label>
                                <input type="radio" name="b" value="fa fa-dashboard" checked>
                                <i class="fa fa-dashboard"></i>
                            </label>
                            <label>
                                <input type="radio" name="b" value="fa fa-pie-chart">
                                <i class="fa fa-pie-chart"></i>
                            </label>
                            <label>
                                <input type="radio" name="b" value="fa fa-joomla">
                                <i class="fa fa-joomla"></i>
                            </label>
                            <label>
                                <input type="radio" name="b" value="fa fa-files-o" checked>
                                <i class="fa fa-files-o"></i>
                            </label>
                            <label>
                                <input type="radio" name="b" value="fa fa-edit">
                                <i class="fa fa-edit"></i>
                            </label>
                            <label>
                                <input type="radio" name="b" value="fa fa-laptop">
                                <i class="fa fa-laptop"></i>
                            </label>
                            <label>
                                <input type="radio" name="b" value="fa fa-laptop">
                                <i class="fa fa-circle-o"></i>
                            </label>
                        </div>

                    </div>
                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label">权限表达式：</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="jurisdiction" name="jurisdiction"
                                   placeholder="请输入权限表达式">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary btn-submit">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>


</body>
</html>
